﻿function resetFBText()
    {
        document.getElementById("ctl00_fb_status").innerHTML = "";
    }
    function submitFeedback()
    {
        var fb = document.getElementById("ctl00_feedbackText").value;
        //alert(fb);
        if (fb=="")
        {
            //alert(fb);
            document.getElementById("ctl00_fb_status").innerHTML = "<img src='Images/error.gif' border='0' style='vertical-align:text-bottom;'></img>&nbsp;" + "Invalid Feedback";
            return;
        }
        document.getElementById("submit_feedback").disabled = true;
        //alert(fb);
        //return;
        try
        {
            var xmlHttp_fb;
            try
            {
                // Firefox, Opera 8.0+, Safari
                xmlHttp_fb=new XMLHttpRequest();
            }
            catch (e)
            {
                // Internet Explorer
                try
                {
                    xmlHttp_fb=new ActiveXObject("Msxml2.XMLHTTP");
                }
                catch (e)
                {
                    try
                    {
                        xmlHttp_fb=new ActiveXObject("Microsoft.XMLHTTP");
                    }
                    catch (e)
                    {
                        //alert("Your browser does not support AJAX!");
                        return false;
                    }
                }
            }
            xmlHttp_fb.onreadystatechange=function()
            {
                if(xmlHttp_fb.readyState==1)
                {
                    document.getElementById("ctl00_fb_status").innerHTML = "<img src='Images/load.gif' border='0' style='vertical-align:text-bottom;'></img>&nbsp;Submitting...";
                }
                if(xmlHttp_fb.readyState==4)
                {
                    //document.myForm.time.value=xmlHttp.responseText;
                    //document.getElementById("ctl00_ContentPlaceHolder2_lblStatus").innerHTML = "&nbsp;";
                    if (xmlHttp_fb.responseText=="success")
                        document.getElementById("ctl00_fb_status").innerHTML = "<img src='Images/tick5.gif' border='0' style='vertical-align:text-bottom;'></img>&nbsp;" + "Success";
                    else
                        document.getElementById("ctl00_fb_status").innerHTML = "<img src='Images/error.gif' border='0' style='vertical-align:text-bottom;'></img>&nbsp;" + xmlHttp_fb.responseText;
                    document.getElementById("submit_feedback").disabled = false;
                    document.getElementById("ctl00_feedbackText").value = "";        
                }
            }
            
            if(document.getElementById("ctl00_hfsendemail")!=null)
            {
                //alert("found");
                if(document.getElementById("ctl00_hfsendemail").value =="admin")
                {
                    if(document.getElementById("ctl00_hfadmin")!=null)
                    {
                    
                    var emailid = document.getElementById("ctl00_hfadmin").value;
                    
                    xmlHttp_fb.open("GET","loadTips.aspx?fb=" + escape(fb)+"&IsMail=false&EMid="+emailid+"",true);
                    }
                    else
                    {
                        xmlHttp_fb.open("GET","loadTips.aspx?fb=" + escape(fb),true);
                    }
                }
                else if(document.getElementById("ctl00_hfsendemail").value =="user")
                {
                    if(document.getElementById("ctl00_hfuser")!=null)
                    {
                        var emailid = document.getElementById("ctl00_hfuser").value;
                        xmlHttp_fb.open("GET","loadTips.aspx?fb=" + escape(fb)+"&IsMail=true&EMid="+emailid+"",true);
                    }
                    else
                    {
                        xmlHttp_fb.open("GET","loadTips.aspx?fb=" + escape(fb),true);
                    }
                }
                else
                {
                   xmlHttp_fb.open("GET","loadTips.aspx?fb=" + escape(fb),true);
                }
                
                
            }
            else
            {
            //alert("Going to redirect");
            xmlHttp_fb.open("GET","loadTips.aspx?fb=" + escape(fb),true);
            }
            xmlHttp_fb.send(null);
            //setTimeout("ajaxFunction()",10000);
        }
        catch(Exxx)
        {
            document.getElementById("submit_feedback").disabled = false;
        }
    }
    
   var randomnumber=Math.floor(Math.random()*1001);//used to make sure that the browser sends the request to the server
    function collapsePanel()
    {  
  randomnumber++;
  var ss = document.getElementById("ctl00_Image1").src;
  ss = ss.indexOf("collapsed2.gif");
  var xmlHttp;
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      try
        {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
      catch (e)
        {
        //alert("Your browser does not support AJAX!");
        return false;
        }
      }
    }
    xmlHttp.onreadystatechange=function()
      {
      if(xmlHttp.readyState==1)
      {
        //document.getElementById("ctl00_ContentPlaceHolder2_lblStatus").innerHTML = "<img src='Images/loading.gif' border='0'></img>";
      }
      if(xmlHttp.readyState==4)
        {
        //document.myForm.time.value=xmlHttp.responseText;
        //document.getElementById("ctl00_ContentPlaceHolder2_lblStatus").innerHTML = "&nbsp;";
        //document.getElementById("ctl00_ContentPlaceHolder2_lblTips").innerHTML = xmlHttp.responseText;        
            /********* Added by 'Imran Gani' (copied from RakaTech) on 05-Sep-2013 for Task & Alerts *********/
            if (document.getElementById("ctl00_ShowReminderList").style.display == "block") {
                document.getElementById("ctl00_ShowReminderList").style.display = "none";
            }
            /********* End of Task & Alerts *********/ 
        }
      }
    xmlHttp.open("GET","loadTips.aspx?rnd=" + randomnumber + "&panelMode=" + ss,true);
    xmlHttp.send(null);
    //setTimeout("ajaxFunction()",10000);
    setTimeout('setDivContentSize()', 200);  // Added by 'Imran Gani' on 19-Sep-2014, for callback of setting content size when collapse the sidebar
  }
  function getDate()
  {
    //include this to make sure that each ajax request is unique
    var sDate = Date();
    //alert(sDate.replace(" ",""));
    return sDate;
  }
  function checkSession()
  {  
  //var randomDate = getDate();
  var xmlHttp;
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      try
        {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
      catch (e)
        {
        //alert("Your browser does not support AJAX!");
        return false;
        }
      }
    }
    xmlHttp.onreadystatechange=function()
      {
      if(xmlHttp.readyState==1)
      {
        //document.getElementById("ctl00_ContentPlaceHolder2_lblStatus").innerHTML = "<img src='Images/loading.gif' border='0'></img>";
      }
      if(xmlHttp.readyState==4)
        {
            var resp = xmlHttp.responseText;
            //alert(resp);      
            if (resp!="validsession")
                window.location.href = resp;
        }
      }
    xmlHttp.open("GET","loadTips.aspx?ses=" + getDate(),true);//checks the session
    xmlHttp.send(null);
    //setTimeout("ajaxFunction()",10000);
  }
function loadTips()
  {  
  return;//don't show tips
  randomnumber++;
  if (document.getElementById("ctl00_ContentPlaceHolder2_lblStatus") != null)
    document.getElementById("ctl00_ContentPlaceHolder2_lblStatus").innerHTML = "";  
  var xmlHttp;
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      try
        {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
      catch (e)
        {
        //alert("Your browser does not support AJAX!");
        return false;
        }
      }
    }
    xmlHttp.onreadystatechange=function()
      {
      if(xmlHttp.readyState==1)
      {
       if (document.getElementById("ctl00_ContentPlaceHolder2_lblStatus") != null)
            document.getElementById("ctl00_ContentPlaceHolder2_lblStatus").innerHTML = "<img src='Images/loading.gif' border='0'></img>";
      }
      if(xmlHttp.readyState==4)
        {
        //document.myForm.time.value=xmlHttp.responseText;
        if (document.getElementById("ctl00_ContentPlaceHolder2_lblStatus") != null)
            document.getElementById("ctl00_ContentPlaceHolder2_lblStatus").innerHTML = "&nbsp;";
        if (document.getElementById("ctl00_ContentPlaceHolder2_lblTips") != null)
            document.getElementById("ctl00_ContentPlaceHolder2_lblTips").innerHTML = xmlHttp.responseText;        
        }
      }
    xmlHttp.open("GET","loadTips.aspx?rnd=" + randomnumber,true);
    xmlHttp.send(null);
    setTimeout("loadTips()",10000);
  }
  
    function showHideDIV(div_id)
    {
        //alert (div_id);
        /*if (document.getElementById(div_id).style.display == "block") {
            document.getElementById("img_" + div_id).title = "Click to expand";
            document.getElementById(div_id).style.display = "none";
            document.getElementById("img_" + div_id).src = "Images/expand3.gif";
        }
        else {
            document.getElementById("img_" + div_id).title = "Click to collapse";
            document.getElementById(div_id).style.display = "block";
            document.getElementById("img_" + div_id).src = "Images/collapse3.gif";
        }
        /*/
        if ($("#" + div_id).is(":hidden")) // Modified by 'Imran Gani' on 10-Dec-12, to use Jquery.
        {
            $("#img_" + div_id).attr("title", "Click to collapse");
            $("#" + div_id).slideDown("", function () { $(this).css("display", "block"); });
            $("#img_" + div_id).attr("src", "Images/collapse3.gif");
        }
        else
        {
            $("#img_" + div_id).attr("title", "Click to expand");
            $("#" + div_id).slideUp("", function () { $(this).css("display", "none"); });
            $("#img_" + div_id).attr("src", "Images/expand3.gif");
        }
    }
    function setfeedBackOnTop()
    {
        try
        {
            if (document.getElementById("ctl00_div_feedback")!= null)
                document.getElementById("ctl00_div_feedback").style.zIndex = 20000;
        }
        catch(Exception4)
        {
            
        }
    }
    
    function Adminclick()
    {
    //alert("adminclick");
        if(document.getElementById("ctl00_hfsendemail")!=null)
        {
            //alert("value updated");
            document.getElementById("ctl00_hfsendemail").value = "admin";
        }
    }
    function UserClick()
    {
    //alert("userclick");
        if(document.getElementById("ctl00_hfsendemail")!=null)
        {
        //alert("value updated");
            document.getElementById("ctl00_hfsendemail").value = "user";
        }
    }
    
    function ShowNextStepDIV()
    {
    
////        if(document.getElementById("ctl00_div_nextstep")!=null)
////        {
////            document.getElementById("ctl00_div_nextstep").style.display="block";
////        }
    }
    function HideNextStepDIV()
    {
    
//        if(document.getElementById("ctl00_div_nextstep")!=null)
//        {
//            document.getElementById("ctl00_div_nextstep").style.display="none";
//        }
    }
    
    function ShowRelatedDIV()
    {
    
//        if(document.getElementById("ctl00_div_related")!=null)
//        {
//            document.getElementById("ctl00_div_related").style.display="block";
//        }
    }
    function HideRelatedDIV()
    {
    
//        if(document.getElementById("ctl00_div_related")!=null)
//        {
//            document.getElementById("ctl00_div_related").style.display="none";
//        }
    }
    /********* Added by 'Imran Gani' (copied from RakaTech) on 05-Sep-2013 for Task & Alerts *********/
    function findPosX(object) {
        var curleft = 0;
        var obj = document.getElementById(object);
        if (obj.offsetParent)
            while (1) {
                curleft += obj.offsetLeft;
                if (!obj.offsetParent)
                    break;
                obj = obj.offsetParent;
            }
        else if (obj.x)
            curleft += obj.x;

        document.getElementById("ctl00_ContentPlaceHolder2_hd_left").value = curleft;
        return curleft;
    }

    function findPosY(object) {
        var curtop = 0;
        var obj = document.getElementById(object);
        if (obj.offsetParent)
            while (1) {
                curtop += obj.offsetTop;
                if (!obj.offsetParent)
                    break;
                obj = obj.offsetParent;
            }
        else if (obj.y)
            curtop += obj.y;

        document.getElementById("ctl00_ContentPlaceHolder2_hd_top").value = curtop - 75;
        return curtop;
    }
    function ShowReminderslist(e) {
        if (document.getElementById("ctl00_ShowReminderList").style.display == "none") {
            $("#ctl00_ShowReminderList")
            .css("top", (findPosY("ctl00_ContentPlaceHolder2_img_reminder") - 75) + "px")
            .css("left", (findPosX("ctl00_ContentPlaceHolder2_img_reminder")) + "px")
            .slideDown("", function () { $(this).css("display", "block"); });
        }
    }
    function closeDiv() {
        if (document.getElementById("ctl00_ShowReminderList").style.display == "block") {
            $("#ctl00_ShowReminderList").slideUp("", function () { $(this).css("display", "none"); });
        }
    }

    function loadReminderonTop() {
        var brow = (navigator.appName);
        if (brow == "Microsoft Internet Explorer") {
            var obj = document.getElementById("ctl00_Panel1");
            obj.setAttribute("class", "collapsePanelIE");
            obj.setAttribute("className", "collapsePanelIE");
        }
        else {
            var obj = document.getElementById("ctl00_Panel1");
            obj.setAttribute("class", "collapsePanel");
            obj.setAttribute("className", "collapsePanel");
        }
    }
    function checkSelection() {
        var grid = document.getElementById("ctl00_Reminders");
        var row = 0;
        var status = false;
        if (grid != null && grid.rows.length > 0) {
            for (row = 0; row < grid.rows.length; row++) {
                if (grid.rows[row].cells[0].childNodes[0].type == "checkbox")
                    if (grid.rows[row].cells[0].childNodes[0].checked == true) {
                        status = true;
                    }
            }
        }
        if (status == false) {
            alert('Please Select a Task ');
        }
        return status;
    }
    function enableReminderButton() {
        if ($("input[type=checkbox]:checked").length > 0) {
            $('#ctl00_task_completed').removeAttr('disabled');
            $('#ctl00_dismiss').removeAttr('disabled');
            if ($('#ctl00_ddl_deferred').val() != "")
                $('#ctl00_defer').removeAttr('disabled');
        }
        else {
            $('#ctl00_task_completed').attr('disabled', 'disabled');
            $('#ctl00_dismiss').attr('disabled', 'disabled');
            $('#ctl00_defer').attr('disabled', 'disabled');
        }
    }
    function enableReminderDeferButton(sVal) {
        if (sVal.value != "" && $("input[type=checkbox]:checked").length > 0) 
            $('#ctl00_defer').removeAttr('disabled');
        else 
            $('#ctl00_defer').attr('disabled', 'disabled');
    }
    /********* End of Task & Alerts *********/

    function setDivContentSize() {  // Added by 'Imran Gani' on 19-Sep-2014, for callback of setting content size when collapse the sidebar
        try {
            var ss = document.getElementById("ctl00_Image1").src;
            ss = ss.indexOf("collapsed2.gif");
            if (ss == -1)
                $("#ctl00_div_content").css("margin-left", "30px");
            else
                $("#ctl00_div_content").css("margin-left", "215px");
        }
        catch (e){ }
    }